<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>IT资产管理系统</title>

    <!-- Bootstrap -->
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/operate.css" rel="stylesheet">
    <link href="../css/time.css" rel="stylesheet">
<!--    <link rel="stylesheet" href="../css/jquery.select.css">-->
    <link rel="stylesheet" href="../css/toastr.min.css">
    <link rel="stylesheet" href="../css/loadStyle.css">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div th:include="common/logo :: logo"></div>
<div class="content">
    <form id="hardware" class="form-horizontal" role="form">
        <fieldset>
            <div class="form-group">
                <label for="AssetsType" class="col-md-1 control-label">类型</label>
                <div class="col-sm-10 " STYLE="width: auto; ">
                    <select id="AssetsType" name="AssetsType" class="form-control select-inline">
                        <option>固定资产</option>
                        <option>非固定资产</option>
                    </select>
                </div>
                <label class="col-sm-1 control-label" for="AssetsCategory">资产类别</label>
                <div class="col-sm-1" style="width: auto">
                    <select id="AssetsCategory" name="AssetsCategory" class="form-control select-inline">
                        <!--必须设定value值,用以修改时设置默认值 -->

                    </select>
                </div>
                <label for="Department" class="col-sm-1 control-label">所属部门</label>
                <div class="col-sm-10 " STYLE="width: auto; ">
                    <select id="Department"name="Department" class="form-control select-inline">
                    </select>
                </div>
                <label class="col-sm-2"></label>

            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label" for="AssetsID">资产号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}" th:value="${Assets.getAssetsID()}"  class="form-control" id="AssetsID" name="AssetsID" type="text" placeholder="格式为:  xxx-xx-xxx" />
                    <input th:if="${Assets==null}"  class="form-control" id="AssetsID" name="AssetsID" type="text" placeholder="格式为:  xxx-xx-xxx" />
                </div>
                <label class="col-sm-1 control-label" for="DeviceID"><span style="color: red">* </span>设备号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getDeviceID()} " th:attr="readonly='readonly'" class="form-control" id="DeviceID" name="DeviceID" type="text" placeholder=""/>
                    <input th:if="${Assets==null}"class="form-control" id="DeviceID" name="DeviceID" type="text" placeholder=""/>
                </div>
                <label class="col-sm-1 control-label" for="FactoryID">出厂编号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getFactoryID()}" class="form-control" id="FactoryID" name="FactoryID" type="text" placeholder=""/>
                    <input th:if="${Assets==null}" class="form-control" id="FactoryID" name="FactoryID" type="text" placeholder=""/>
                </div>
                <label class="col-sm-1 control-label" for="AssetsName">资产名称</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getAssetsName()}" class="form-control" id="AssetsName" name="AssetsName" type="text" placeholder=""/>
                    <input th:if="${Assets==null}" class="form-control" id="AssetsName" name="AssetsName" type="text" placeholder=""/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label" for="Models">规格型号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getModels()}"  class="form-control" id="Models" name="Models" type="text" placeholder=""/>
                    <input th:if="${Assets==null}" class="form-control" id="Models" name="Models" type="text" placeholder=""/>
                </div>
                <label class="col-sm-1 control-label" for="Supplier">供应商</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getSupplier()}"class="form-control" id="Supplier" name="Supplier" type="text" placeholder=""/>
                    <input th:if="${Assets==null}"class="form-control" id="Supplier" name="Supplier" type="text" placeholder=""/>
                </div>
                <label for="PersonliableID" class="col-sm-1 control-label">责任人工号</label>
                <div class="col-sm-2 " >
                    <input th:if="${Assets!=null}"th:value="${Assets.getPersonliableID()}"id="PersonliableID" name="PersonliableID" class="form-control" value=""/>
                    <input th:if="${Assets==null}" id="PersonliableID" name="PersonliableID" class="form-control" value=""/>
                </div>
                <label for="Personliable" class="col-sm-1 control-label">责任人</label>
                <div class="col-sm-1 ">
                    <input th:if="${Assets!=null}"th:value="${Assets.getPersonliable()}"class="form-control" id="Personliable" name="Personliable"  type="text" placeholder=""/>
                    <input th:if="${Assets==null}" class="form-control" id="Personliable" name="Personliable"  type="text" placeholder=""/>
                </div>
            </div>
            <div class="form-group">
                <label for="FaArea" class="col-sm-1 control-label">厂区</label>
                <div class="col-sm-2 " >
                    <select id="FaArea" name="FaArea" class="form-control select-inline" value="">
                        <option>东莞</option>
                        <option>惠州</option>
                    </select>
                </div>
                <label for="Area" class="col-sm-1 control-label">区域</label>
                <div class="col-sm-2 " >
                    <select  id="Area" name="Area" class="form-control select-inline" value="">
                    </select>
                </div>
                <label for="Location" class="col-sm-1 control-label">详细位置</label>
                <div class="col-sm-2 " >
                    <input th:if="${Assets!=null}"th:value="${Assets.getLocation()}" id="Location" name="Location" class="form-control" value=""/>
                    <input th:if="${Assets==null}" id="Location" name="Location" class="form-control" value=""/>
                </div>


                <label for="ProductionSetp" class="col-sm-1 control-label">工序</label>
                <div class="col-sm-2 " >
                  <select id="ProductionSetp" name="ProductionSetp" class="form-control select-inline" value="">

                </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label" for="PState">性能状态</label>
                <div class="col-sm-2">
                    <select id="PState" name="PState" class="form-control select-inline" value="">
                    </select>
                </div>
                <label class="col-sm-1 control-label" for="AState">资产状态</label>
                <div class="col-sm-2">
                    <select id="AState" name="AState" class="form-control select-inline" value="">
                    </select>
                </div>
                <label class="col-sm-1 control-label" for="RequireID">需求报告编号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}" th:value="${Assets.getRequireID()}"class="form-control" id="RequireID" name="RequireID" type="text" placeholder="">
                    <input th:if="${Assets==null}" class="form-control" id="RequireID" name="RequireID" type="text" placeholder="">
                </div>
                <label class="col-sm-1 control-label" for="AgreementID">技术协议号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}" th:value="${Assets.getAgreementID()}"class="form-control" id="AgreementID" name="AgreementID" type="text" placeholder="">
                    <input th:if="${Assets==null}" class="form-control" id="AgreementID" name="AgreementID" type="text" placeholder="">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label" for="ContractID">合同号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getContractID()}"class="form-control" id="ContractID" name="ContractID" type="text" placeholder="">
                    <input th:if="${Assets==null}"class="form-control" id="ContractID" name="ContractID" type="text" placeholder="">
                </div>
                <label class="col-sm-1 control-label" for="ReceiptID">收货单号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getReceiptID()}"class="form-control" id="ReceiptID" name="ReceiptID" type="text" placeholder="">
                    <input th:if="${Assets==null}"class="form-control" id="ReceiptID" name="ReceiptID" type="text" placeholder="">
                </div>
                <label class="col-sm-1 control-label" for="CheckID">验收单号</label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getCheckID()}" class="form-control" id="CheckID" name="CheckID" type="text" placeholder="">
                    <input th:if="${Assets==null}" class="form-control" id="CheckID" name="CheckID" type="text" placeholder="">
                </div>
                <label for="Entrydate" class="col-sm-1 control-label">入厂日期</label>
                <div class="input-group date form_date col-sm-2"   data-link-field="Entrydate" >
                    <input th:if="${Assets!=null}"th:value="${Assets.getEntryDate()}" id="endate" class="form-control" size="16" name="EntryDate" type="text" value="" readonly>
                    <input th:if="${Assets==null}" id="endate" class="form-control" size="16" name="EntryDate" type="text" value="" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                </div>
                <input  type="hidden" id="Entrydate" value="" /><br/>
            </div>


            <div class="form-group">
                <label class="col-sm-1 control-label" for="OutID">报废/转售单号 </label>
                <div class="col-sm-2">
                    <input th:if="${Assets!=null}"th:value="${Assets.getOutID()}" class="form-control" id="OutID" name="OutID" type="text" placeholder="没有则不填"/>
                    <input th:if="${Assets==null}" class="form-control" id="OutID" name="OutID" type="text" placeholder="没有则不填"/>
                </div>
                <label class="col-sm-1 control-label" for="Remark">备注 </label>
                <div class="col-sm-5">
                    <textarea  class="form-control" id="Remark" name="Remark" rows="1" placeholder="没有则不填"></textarea>
                </div>

            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label" for="UserID">使用人工号</label>
                <div class="col-sm-2">
                    <input th:if="${user!=null}"th:value="${user.getUserID()}" class="form-control" id="UserID" name="UserID" type="text" placeholder="没有则不填"/>
                    <input th:if="${user==null}"class="form-control" id="UserID" name="UserID" type="text" placeholder="没有则不填"/>
                </div>
                <label class="col-sm-1 control-label" for="UserName" >使用人</label>
                <div class="col-sm-1">
                    <input th:if="${user!=null}"th:value="${user.getUserName()}" class="form-control" id="UserName" name="UserName"  type="text" placeholder=""/>
                    <input th:if="${user==null}"class="form-control" id="UserName" name="UserName"  type="text" placeholder=""/>
                </div>
                <label class="col-sm-2 control-label" for="UserDepartment">使用部门</label>
                <div class="col-sm-2">
                    <select id="UserDepartment" name="UserDepartment" class="form-control select-inline">
                    </select>
                </div>
            </div>
        </fieldset>
        <div class="form-group" style="text-align: center">
            <input th:if="${Assets==null}" id="commit" type="button" class="btn btn-primary" value="保存" style="width: 30%">
            <input th:if="${Assets!=null}" id="update2" type="button" class="btn btn-primary" value="更新" style="width: 30%">
        </div>
    </form>
    <!-- Modal copy -->
<!--    <div class="modal fade" id="update" tabindex="-1" role="dialog" aria-labelledby="update">-->
<!--        <div class="modal-dialog" role="document">-->
<!--            <div class="modal-content">-->
<!--                <div class="modal-header">-->
<!--                    <button type="button" id="close" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>-->
<!--                    <h4 class="modal-title" id="modal2">选择文件上传</h4>-->
<!--                </div>-->
<!--                <div class="modal-body">-->
<!--                    <div style="text-align: center">-->
<!--                        <div  STYLE="width: auto; ">-->
<!--                            <label for="AssetsType" >上传类型</label>-->
<!--                            <br>-->
<!--                            <select id="Uptype"  style="width: auto; border: 1px solid #CCC;padding: 0.6rem 1.2rem;border-radius: 0.4rem;">-->
<!--                                <option>资产</option>-->
<!--                                <option>IT</option>-->
<!--                            </select>-->
<!--                        </div>-->
<!--                            <br>-->
<!--                        <form id="upForm" method="post" action="#" enctype="multipart/form-data">-->
<!--                            <input id="uploadFile" placeholder="Choose File" disabled="disabled" />-->
<!--                            <div class="fileUpload btn btn-primary">-->
<!--                                <span><span class="glyphicon glyphicon-upload"></span>选择文件</span>-->
<!--                                <input id="uploadBtn" type="file" name="file"  class="upload" />-->
<!--                            </div>-->
<!--                        </form>-->

<!--                    </div>-->
<!--                </div>-->
<!--                <div class="modal-footer">-->
<!--                    <button id="uploadButton" type="button" class="fileUpload btn btn-warning" onclick="uploadfile();">上传</button>-->
<!--                    &lt;!&ndash; 加载动画 &ndash;&gt;-->
<!--                    <div id="loading" class="container&#45;&#45;box">-->
<!--                        <div class="box">-->
<!--                            <div class="spinner spinner&#45;&#45;3"></div>-->
<!--                            处理中...-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
    <!-- Modal copy2 -->
<!--    <div class="modal fade" id="download" tabindex="-1" role="dialog" aria-labelledby="example">-->
<!--        <div class="modal-dialog" role="document">-->
<!--            <div class="modal-content">-->
<!--                <div class="modal-header">-->
<!--                    <button type="button" id="close2" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>-->
<!--                    <h4 class="modal-title" >选择要下载的示例</h4>-->
<!--                </div>-->
<!--                <div class="modal-body">-->
<!--                    <div style="text-align: center">-->
<!--                        <a type="button" href="/itams/download/Example?name=Assets" class="btn btn-primary" style="width: auto;">下载资产示例</a>-->
<!--&lt;!&ndash;                        <br>&ndash;&gt;-->
<!--&lt;!&ndash;                        <br>&ndash;&gt;-->
<!--&lt;!&ndash;                        <a type="button" href="/itams/download/Example?name=IT" class="btn btn-primary" style="width: auto;">下载IT资产信息示例</a>&ndash;&gt;-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
</div>

</body>
<script src="../js/jquery-3.4.0.min.js"></script>
<!--<script src="../js/jquery.select.js"></script>-->
<script src="../js/bootstrap.min.js"></script>
<script src="../js/operate/op.js"></script>
<script type="text/javascript" src="../js/time.js" charset="UTF-8"></script>
<script src="../js/toastr.min.js"></script>
<script src="../js/operate/upload.js"></script>
<script type="text/javascript" th:inline="javascript">
    $(document).ready(function() {
        //隐藏加载动画
        $("#loading").hide();
        //修改时,将值赋到HTML中.
        var assets = [[${Assets}]];
        var user = [[${user}]];
        //获取下拉菜单的值
        setSelectValue();


        //设置selected属性,需要在初始化控件前完成
        if(assets!=null){
           // setSelectedOption("#AssetsCategory", assets.assetsCategory);
            setTimeout(function () {
                setSelectedOption("#Department", assets.department);
                setSelectedOption("#FaArea", assets.faArea);
                setSelectedOption("#Area", assets.area);
                setSelectedOption("#ProductionSetp", assets.productionSetp);
                setSelectedOption("#PState", assets.pstate);
                setSelectedOption("#AState", assets.astate);
                if(user!=null){
                    setSelectedOption("#UserDepartment", user.userDepartment);
                }
                $('#Remark').val(assets.remark) //设置备注的值
            },200)

        }


        // $('#Department').editableSelect({  //带输入的下拉框
        //     filter:false,  effects: 'slide'
        // });
        // $('#Area').editableSelect({  //带输入的下拉框
        //     filter:false,effects: 'slide'
        // });
        // $('#ProductionSetp').editableSelect({  //带输入的下拉框
        //     filter:false, effects: 'slide'
        // });
        // $('#UserDepartment').editableSelect({  //带输入的下拉框
        //     filter:false, effects: 'slide'
        // });


    })
    //设置页面初始化时的选项
    function setSelectedOption(selector, value){
        if (value!=null && value.length !=0) {
            $(selector +" > option[value='"+value+"']").attr("selected",true);
        }
    }
    $('.form_date').datetimepicker({
        format: 'yyyy-mm-dd',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0
    });
    // document.getElementById("uploadBtn").onchange = function () { //上传按钮合一
    //     document.getElementById("uploadFile").value = this.value;
    // };

    /*插入更新前的判断操作.*/

</script>
</body>
</html>
